package servlet.car;

import domain.Car;
import service.CarsService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/UpdateCarServlet")
public class UpdateCarServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        HttpSession session = request.getSession();
        String goods_price = request.getParameter("goods_sprice"); //  goods 传进来没   请求一下
        int num = Integer.parseInt(request.getParameter("num"));
        int id = Integer.parseInt(request.getParameter("id"));
        session.setAttribute("zj", goods_price);
        session.setAttribute("sl", num);
        CarsService carsService = new CarsService();
        Car c = carsService.findCarMsgById(id);
        carsService.findCarMsgById(id);
        request.setAttribute("car", c);
        request.getRequestDispatcher("updateCar.jsp").forward(request, response);
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
